cmake_minimum_required(VERSION 3.4.1)
project(sqlite3x)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_USLEEP=1")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSQLITE_HAVE_ISNAN")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSQLITE_THREADSAFE=2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSQLITE_TEMP_STORE=3")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSQLITE_POWERSAFE_OVERWRITE=1")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSQLITE_DEFAULT_FILE_FORMAT=4")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSQLITE_DEFAULT_AUTOVACUUM=1")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSQLITE_ENABLE_FTS3")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSQLITE_ENABLE_FTS3_PARENTHESIS")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSQLITE_ENABLE_FTS4")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSQLITE_ENABLE_FTS4_PARENTHESIS")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSQLITE_ENABLE_FTS5")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSQLITE_ENABLE_FTS5_PARENTHESIS")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSQLITE_ENABLE_JSON1")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSQLITE_ENABLE_RTREE=1")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSQLITE_UNTESTABLE")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSQLITE_OMIT_COMPILEOPTION_DIAGS")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSQLITE_DEFAULT_FILE_PERMISSIONS=0600")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSQLITE_DEFAULT_MEMSTATUS=0")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSQLITE_MAX_EXPR_DEPTH=0")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSQLITE_USE_ALLOCA")
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSQLITE_ENABLE_BATCH_ATOMIC_WRITE")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DO3")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNDEBUG=1")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPACKED=__attribute((packed))")

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-parameter -Wno-int-to-pointer-cast")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-uninitialized -Wno-parentheses")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --Wno-conversion-null")

add_library(sqlite3x SHARED    sqlite/openharmony_database_SQLiteCommon.cpp
                               sqlite/openharmony_database_SQLiteConnection.cpp
                               sqlite/openharmony_database_SQLiteFunction.cpp
                               sqlite/openharmony_database_SQLiteGlobal.cpp
                               sqlite/openharmony_database_SQLiteDebug.cpp
                               sqlite/openharmony_database_CursorWindow.cpp
                               sqlite/CursorWindow.cpp
                               sqlite/JNIHelp.cpp
                               sqlite/JNIString.cpp
                               sqlite/sqlite3.c )

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/sqlite)

target_link_libraries( sqlite3x
                       hilog_ndk.z
                       dl
                       c)